# This file contains the fastlane.tools configuration
# You can find the documentation at https://docs.fastlane.tools
#
# For a list of all available actions, check out
#
#     https://docs.fastlane.tools/actions
#
# For a list of all available plugins, check out
#
#     https://docs.fastlane.tools/plugins/available-plugins
#

# Uncomment the line if you want fastlane to automatically update itself
# update_fastlane

default_platform(:android)

platform :android do
    desc "Runs all the tests"
    lane :test do
        gradle(task: "test")
    end

    desc "Build ci test"
    lane :ci do
        gradle(
            task: "clean assemble",
            flavor: "ci",
            build_type: 'Release',
            print_command: true
        )

        # sh "your_script.sh"
        # You can also use other beta testing services here
    end

    desc "Build google play package"
    lane :play do
        gradle(
            task: "clean assemble",
            flavor: "play",
            build_type: 'Release',
            print_command: true
        )

        gradle(
            task: "bundle",
            flavor: "play",
            build_type: 'Release',
            print_command: true
        )

        # sh "your_script.sh"
        # You can also use other beta testing services here
    end

    desc "Deploy a new version to the Google Play"
    lane :upload2GooglePlay do |options|
        if options[:aabPath]
            puts "aabPath:#{options[:aabPath]}"
            upload_to_play_store(
                aab: options[:aabPath],
                track: 'internal',
                skip_upload_apk: true,
                skip_upload_metadata: true,
                skip_upload_changelogs: true,
                skip_upload_images: true,
                skip_upload_screenshots: true,
                release_status: "draft",
                changes_not_sent_for_review: true
            )
        else
            upload_to_play_store(
                aab: "app/build/outputs/bundle/playRelease/app-play-release.aab",
                track: 'internal',
                skip_upload_apk: true,
                skip_upload_metadata: true,
                skip_upload_changelogs: true,
                skip_upload_images: true,
                skip_upload_screenshots: true,
                release_status: "draft",
                changes_not_sent_for_review: true
            )
        end
    end
end
